package top.lingkang.screen;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import top.lingkang.CoolRunGame;

public class WelcomeScreen extends GameScreen {
    private CoolRunGame game;
    private Stage stage;
    private Label start;
    private boolean leave_current_screen = false;

    public WelcomeScreen(CoolRunGame game) {
        this.game = game;
        stage = game.stage;
        Label.LabelStyle font = new Label.LabelStyle(game.bitmapFont, Color.WHITE);
        start = new Label("Click anywhere to start the game", font);
        start.setPosition(300, 240);
        stage.addActor(start);
    }

    @Override
    public void render(float delta) {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        stage.draw();
        if (!leave_current_screen && (Gdx.input.isTouched() || Gdx.input.isKeyPressed(Input.Keys.ANY_KEY))) {
            leave_current_screen = true;
            System.out.println("start game!");
            // 进入玩游戏场景
            game.setScreen(new PlayScreen(game));
            dispose();
        }
    }

    @Override
    public void dispose() {
    }
}
